package com.jingbian.cppccbackend.mapper.admin;

import com.jingbian.cppccbackend.entity.Meetings;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jingbian.cppccbackend.entity.Users;
import com.jingbian.cppccbackend.entity.vo.MeetingDetailVO;
import com.jingbian.cppccbackend.entity.MeetingAttachments;
import com.jingbian.cppccbackend.entity.MeetingParticipants;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 会议表，用于存储会议基本信息 Mapper 接口
 * </p>
 *
 * @author yezi
 * @since 2025-02-26
 */
@Mapper
public interface adminMeetingsMapper extends BaseMapper<Meetings> {

    List<Meetings> getMeetings(String sortType,String startDate, String endDate, String searchText,String status,Boolean isMeeting);

    List<Meetings> getEndedMeetings(String sortType, String startDate, String endDate, String searchText, String status, Boolean isMeeting);
    
    // 获取会议详情
    Meetings getMeetingById(Integer mid);
    
    // 获取参会人详细信息
    List<MeetingDetailVO.ParticipantInfo> getMeetingParticipants(Integer mid);

    List<Users> getParticipants(String identity, String region, String affiliation, String searchText);

    // 插入附件信息
    int insertAttachment(MeetingAttachments attachment);
    
    // 插入参会人信息
    int insertParticipant(MeetingParticipants participant);

    // 获取会议附件信息
    List<MeetingDetailVO.AttachmentInfo> getMeetingAttachments(Integer mid);

    // 删除会议附件
    int deleteAttachment(Integer aid);
    
    // 删除会议所有参会人
    int deleteAllParticipants(Integer mid);

    // 根据ID获取附件信息
    MeetingAttachments getAttachmentById(Integer aid);

    // 获取今日会议数量
    @Select("SELECT COUNT(*) FROM meetings WHERE DATE(start_time) = CURDATE() AND is_meeting = true")
    Integer getTodayMeetingsCount();

    // 获取已结束会议数量
    @Select("SELECT COUNT(*) FROM meetings WHERE end_time < NOW() AND is_meeting = true")
    Integer getEndedMeetingsCount();

    // 获取会议总数
    @Select("SELECT COUNT(*) FROM meetings WHERE is_meeting = true")
    Integer getTotalMeetingsCount();
    // 获取会议发布趋势
    List<Map<String, Object>> getMeetingTrend(String startDate, String endDate);
}
